<template>
	<view class="container">
		<view class="" v-if="!datas">
			<!-- <button style="border-radius: 100%;background-color: bisque;width: 50px;height: 50px;display: inline-block;margin-left: 20px;"></button> -->
			<image src="../../static/logo.png" mode="" style="height: 80px; width: 80px;border-radius: 50%;"></image>
			<navigator url="login/login" open-type="navigate" style="display: flex;flex-direction: column;align-items: center;">
				<Button type="default" style="width: 90%;height: 50px;background-color: #f8f8f8;border: 1px solid #ccc;" @click="login">
					登录
				</Button>
			</navigator>
		</view>
		<view class="" v-else>
			<image :src="'http://localhost:8090'+datas.icon" mode="" style="width: 80px;height: 80px;border-radius: 50%;" @click="upimg"></image>
			<uni-list>
				<uni-list-item title="修改密码" note=""></uni-list-item>
				<uni-list-item title="电话" note="" :right-text="datas.telephone"></uni-list-item>
			</uni-list>
			<button @click="outLogin">退出登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// flag:true,
				datas:{}
			}
		},
		methods: {
			login(){
				uni.reLaunch({
					url:'./login/login'
				})
			},
			outLogin(){
				this.datas=uni.removeStorageSync('formdata')
			},
			upimg(){
				uni.chooseImage({
					count:1,
					success: (res) => {
						// console.log(res);
						uni.uploadFile({
							url:'http://localhost:8090/foodapp/uploadheadicon',
							filePath:res.tempFilePaths[0],
							header:{
								"content-type":"form-data"
							},
							success: (re) => {
								// console.log(re);
								this.datas.icon= JSON.parse(re.data).fileName
							}
						})
					}
				})
			}
		},
		// onLoad: () => {
		// 	uni.onTabBarMidButtonTap(function(e) {
		// 		console.log(e)

		// 	})
		// }
		onShow() {
			this.datas=uni.getStorageSync('formdata');
			console.log(this.data);
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
